<% sectionable_type = section.sectionable.andand.class.to_s.demodulize.underscore %>
<li id="section_<%=guid%>" class="<%= sectionable_type.camelcase(:lower) %> <%= section.sectionable.andand.errors.any? ? "invalid" : "" %>">
  <%= variant_form.fields_for "sections_attributes", section, :index => guid do |section_form| %>
    <%= section_form.hidden_field :id unless section_form.object.new_record? %>
    <%= section_form.hidden_field :_destroy, :class => "delete" %>
    <%= section_form.positioning_field %>
    
    <%= section_form.fields_for "sectionable_attributes", section_form.object.sectionable do |sectionable_form| %>
      <%= sectionable_form.hidden_field :id unless sectionable_form.object.new_record? %>
      <%= sectionable_form.hidden_field :class if sectionable_form.object.new_record? %>    

      <div class="undestroy">
        <%= link_to_function button_text(:undo), "PageHelper.unDestroy('section_#{guid}')", :class => "undo button small" %>
        <%= t(:will_be_destroyed, :section => section.sectionable.class.model_name.human, :scope => [:section, :form]) %>
      </div>  
      <div class="section">   	        
        <% if section.sectionable.default_interface %>
        	<div class="head">    		      	
        		<div class="tools">
        		  <%= renderable_templates_select(section.sectionable, section_form) %>
        		</div>
        		<%= section.sectionable.class.model_name.human %>
        	</div>
        	<div class="body">
            <%= render :partial => "skyline/sections/#{sectionable_type}", :locals => {:section_form => section_form, :sectionable_form => sectionable_form, :guid => guid} %>
    	    </div>
        <% else %>
          <%= render :partial => "skyline/sections/#{sectionable_type}", :locals => {:section_form => section_form, :sectionable_form => sectionable_form, :guid => guid} %>
        <% end %>
      </div>
    <% end %>        

  <% end %>
  
  <ul class="sectiontools">
    <li class="drag">
      <span class="drag dragSection">&nbsp;</span>
    </li>
    <li>
      <%= link_to_function(image_tag("#{Skyline::Configuration.url_prefix}/images/buttons/section-delete.gif", :alt => t(:delete, :scope => [:section, :form])), "PageHelper.destroy('section_#{guid}')", :class => "delete") %>    
    </li>
  </ul>
</li>

<%= javascript_tag "PageHelper.destroy('section_#{guid}');" if section.marked_for_destruction? %>